Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Initializer Testing #1170

Merged
merged 34 commits into from
Apr 19, 2023
Merged

More Initializer Testing #1170

merged 34 commits into from
Apr 19, 2023

Conversation

andrewlee94
Copy link
Member

Fixes None

Summary/Motivation:

This PR adds more testing and refinement of Initializers for core unit models.

Changes proposed in this PR:

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the license terms described in the LICENSE.txt file at the top level of this directory.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@andrewlee94 andrewlee94 self-assigned this Apr 18, 2023
@andrewlee94 andrewlee94 added enhancement New feature or request Priority:Normal Normal Priority Issue or PR core Issues dealing with core modeling components property packages Issues dealing with properties unit models Issues dealing with the unit model libraries labels Apr 18, 2023
"in models that involve ExternalFunctions. We suggest you try "
"setting calculate_variable_options=\u007b'diff_mode': "
"pyomo.core.expr.calculus.differentiate.Modes.reverse_numeric\u007d. "
)
Copy link
Member

@eslickj eslickj Apr 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this, but is this because you are using sympy for derivatives? Could you use pynumero?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a Pyomo tool so that is a question for them, but yes it is because they are using sympy by default for the derivatives.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsiirola I don't want to put in the effort to trace this back and file a pyomo issue. Is it possible to fall back on pynumero (or maybe more of a stretch make sympy understand AMPL functions? Or just have a pynumero derivative option?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eslickj, this is orthogonal to pynumero. But yes, it is possible to automatically fall back on numeric differentiation (or just always use numeric differentiation). I just pushed up Pyomo/pyomo#2812 to have calculate_variable_from_constraint() automatically fall back on numeric differentiation if symbolic fails (and the user didn't care what differentiation engine to use).

@codecov
Copy link

codecov bot commented Apr 18, 2023

Codecov Report

Patch coverage: 24.20% and project coverage change: -0.36 ⚠️

Comparison is base (a195138) 76.67% compared to head (2a95be8) 76.32%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1170      +/-   ##
==========================================
- Coverage   76.67%   76.32%   -0.36%     
==========================================
  Files         369      369              
  Lines       60306    60613     +307     
  Branches    11087    11187     +100     
==========================================
+ Hits        46237    46260      +23     
- Misses      11665    11966     +301     
+ Partials     2404     2387      -17     
Impacted Files Coverage Δ
...ls/properties/general_helmholtz/helmholtz_state.py 95.49% <ø> (ø)
...erties/modular_properties/base/generic_property.py 60.68% <ø> (-3.17%) ⬇️
idaes/models/unit_models/separator.py 67.99% <4.70%> (-9.08%) ⬇️
idaes/models/unit_models/mixer.py 74.74% <7.84%> (-10.13%) ⬇️
idaes/models/unit_models/pressure_changer.py 66.59% <8.82%> (-10.48%) ⬇️
idaes/models/unit_models/heat_exchanger.py 77.61% <11.90%> (-11.75%) ⬇️
.../activity_coeff_models/activity_coeff_prop_pack.py 79.58% <82.53%> (+0.91%) ⬆️
idaes/core/initialization/general_hierarchical.py 85.24% <100.00%> (+3.27%) ⬆️
idaes/core/initialization/initializer_base.py 89.18% <100.00%> (+3.92%) ⬆️
idaes/models/unit_models/product.py 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@andrewlee94 andrewlee94 merged commit 1e75901 into IDAES:main Apr 19, 2023
@andrewlee94 andrewlee94 deleted the initializers_4 branch April 19, 2023 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues dealing with core modeling components enhancement New feature or request Priority:Normal Normal Priority Issue or PR property packages Issues dealing with properties unit models Issues dealing with the unit model libraries
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants